<div id="includingStuff">
    <!--include js/css-->
    <?php Yii::app()->clientScript->registerCssFile(
        Yii::app()->baseUrl . '/css/stock/stock.css'
    ); ?>

    <!--Yii's default script.-->
    <?php
        Yii::app()->clientScript->registerScript(
            'search',
            "
            $('.search-button').click(function() {
                $('.search-form').toggle();
                return false;
            });
            $('.search-form form').submit(function() {
                $.fn.yiiGridView.update('stock-grid', {
                    data: $(this).serialize()
                });
                return false;
            });
            "
        );
    ?>
</div><!--includingStuff-->

<!--Sub-menu-->
<?php require __DIR__ . '/_submenu.php'; ?>

<h1>Manage Stocks</h1>

<div id="searchFormWrapper">
    <div id="searchButton">
        <?php echo CHtml::link('Search', '#', array('class' => 'search-button')); ?>
    </div>

    <div id="searchForm" class="search-form" style="display:none">
        <?php
        $this->renderPartial('_search', array(
            'model' => $model,
        ));
        ?>
    </div>
</div><!-- Search-form-->

<!--The Stock Grid-->
<?php
    $afterUpdate = "js:function(id, data) {jQuery('#datepicker').datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, yearRange: '-20:+20', constraint: true});}";
    $datetimeFilter = $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'timestamp',
                // additional javascript options for the date picker plugin
                'options' => array(
                    'showAnim' => 'fold',
                    'dateFormat' => 'dd/mm/yy',
                    'changeMonth' => true,
                    'changeYear' => true,
                    'yearRange' => '-20:+20',
                    'constrainInput' => true,
                ),
                'htmlOptions' => array(
                    'id' => 'datepicker'
                ),
            ),true);
    
    
    $this->renderPartial('_inlineEditor', array(
        'model' => $model,
        'dataProvider' => $model->search(),
        'filter' => $model,
        'afterUpdate' => $afterUpdate,
        'datetimeFilter' => $datetimeFilter,
    ))
?>